package com.zhanghp.demo01.commands;

import com.zhanghp.demo01.editor.Editor;

import java.awt.*;
import com.zhanghp.demo01.shap.Shape;


/**
 * @author zhanghp
 * @date 2022-09-13 17:46
 */
public class ColorCommand implements Command{
    private Editor editor;
    private Color color;

    public ColorCommand(Editor editor, Color color) {
        this.editor = editor;
        this.color = color;
    }

    @Override
    public String getName() {
        return "Colorize: " + color.toString();
    }

    @Override
    public void execute() {
        for (Shape child : editor.getShapes().getSelected()) {
            child.setColor(color);
        }
    }
}
